package robocup.component.tactics;

import robocup.component.SConf;
import robocup.component.ControllerNumbers.PLAY_MODE;

public class ShootGoalState
    extends AbstractState {

  /**
   * Constructor calls superclass constructor
   */
  public ShootGoalState(
      final StateEvaluation parent) {

    super(parent);
    this.state = STATES.SHOOT_GOAL;
  }

  /**
   * Precondition is set up by player has ball, defined in AbstractState.
   * @return true if we possibly can shoot a goal
   */
  @Override
  public boolean preCondition() {

    if (!this.checkPlayMode()) {
      return false;
    }

    if (this.getWorld().getNumber() == 10 && PLAY_MODE.META_PENALTY_OWN
        .contains(this.getWorld().getPlayMode())) {
      if (this.getWorld().canKick()) {
        return true;
      }
      return false;
    }

    if (PLAY_MODE.META_PENALTY_OWN.contains(this.getWorld().getPlayMode())) {
      return false;
    }

    final boolean pre = (this.checkPlayMode() && (this.getPlayer().canKick(getWorld().getBallRef())) && this
        .getPlayer().getDistance(SConf.getInstance().GOAL_POS_OTHER) < 35);

    return pre;
  }

  /**
   * The Probability of scoring a goal is calculated inside the worldmodel (up
   * to now).
   */
  @Override
  protected double successProbability() {

    return this.getProphet().getScoreBenefit();
  }

  /**
   * The benefit is max - a goal is our goal!
   * 
   * @return 1 - always
   */
  @Override
  protected double successBenefit() {

    return 1;
  }

  @Override
  public void calculateMainAction() {

    this.mainAction = this.getProphet().getScoreAction();
  }
  
  @Override
  public void calculateTurnNeckAction() {
    
    super.calculateTurnNeckAction();
  }
}

/**
 * $Log: ShootGoalState.java,v $ Revision 1.8 2006/11/05 13:58:02 wetzker more
 * merging - CLang + MF + some states still missing
 * 
 * Revision 1.7 2006/06/10 23:21:21 wetzker better kick'n'run (sometimes we
 * don't kick but go with the ball) security for passes to teammates near the
 * opps goal set to max clear ball now should always lead to an action
 * 
 * Revision 1.6 2006/06/05 17:50:42 gamel added penalty handling Revision 1.5
 * 2006/05/23 17:40:02 wetzker added new dribbling (still much to do but better
 * than before :-) added new role-model (see player.java) debugged clear ball,
 * kickNRun,Passing, InterceptBall, NR
 * 
 * Revision 1.4 2006/05/15 13:13:20 wetzker added new dribbling (by now only
 * wait with ball) added new clear ball adjusted interceptBall (please report
 * bugs) created new AttentionTo- und modified SayModel
 * 
 * Revision 1.3 2006/03/26 21:58:40 wetzker created geometry package and moved
 * geometry classes from worldobject package there
 * 
 * Revision 1.2 2006/03/26 20:10:00 wetzker each player now contains its known
 * states and the playmodes of each state
 * 
 * Revision 1.1 2006/03/13 07:36:31 axle moved from ROOT/src for Maven 2
 * Buildsystem and Team/Soccerscope separation
 * 
 * Revision 1.15 2006/03/07 12:46:12 endert Merge after refactoring: - New
 * State-Interface: One Method for each action type - Action Bean removed -
 * ActionFactorys for helper methods, States calculate main-Action themselves -
 * formatted code - added State-List in Monitor (Context-Menu of Player) - other
 * smaller stuff
 * 
 * Revision 1.14.2.3 2006/02/28 16:58:06 endert Organized imports, outsourced
 * unused vars, removed warnings!
 * 
 * Revision 1.14.2.2 2006/02/28 16:43:09 endert Changed State-Interface:
 * -resetState() -calculateXYAction() Usage of ActionFactories (no higher level
 * actions, these should be calculated in calculateMainAction()), Set
 * getAction() to deprecated and retactoring of variable names (wm ->
 * getWorld())
 * 
 * Revision 1.14.2.1 2006/02/25 22:07:17 wetzker formated
 * 
 * Revision 1.14 2006/02/24 18:53:47 wetzker used enums for Play_modes and
 * Referee_messages - still has to be improved after creation of new
 * Play_mode-Model - tagged old version removed millions of warnings
 * 
 * Revision 1.13 2006/02/22 16:04:31 endert This is done: - Rebound SoccerScope
 * to Agents (can be added or removed in config-file) - Situations now all
 * extend abstract class Situation - Refactorings: ActionBean _ removed from
 * Attributes - SoccerScope will automatically connect to host given in
 * Start-Call - Trainer uses the same host as soccerscope - Removed unused stuff
 * (old confs, bat, etc.) - Code formatted (good luck when merging) - organized
 * imports - all that i forgot to mention here Revision 1.12 2006/02/06 20:42:53
 * endert New Say-Method in Action Bean, which is called after execAcion in
 * StateEvaluation
 * 
 * Revision 1.11 2006/02/06 18:11:14 wetzker refactored, farmatted and cleaned
 * the states Revision 1.10 2006/02/06 17:09:39 endert New Communication merged,
 * bla bla
 * 
 * Revision 1.9 2006/02/06 08:35:39 wetzker added new Scoring Function which
 * still has to be improved after new communication model - improved most models
 * and corrected collision model - made some refactoring - (tagged old version)
 * 
 * Revision 1.8.24.1 2005/11/24 21:58:31 wetzker added score situation and
 * collision model debugged ball update remove Time-Class removed some unused
 * states
 * 
 * Revision 1.8 2005/09/09 12:36:45 endert New Defense (Branch) with simple
 * back-four merged into head!
 * 
 * Revision 1.7.2.1 2005/09/05 12:16:24 endert Branch with a new defense
 * (back-four)
 * 
 * Revision 1.7 2005/08/16 16:26:33 wetzker merged composite branch
 * 
 * Revision 1.5.2.8 2005/08/14 15:21:34 wetzker improved passing improved
 * performance of inteceptBallSituation improved scoring -> now special case in
 * passSituation -> uses gaussian distribution (added package) -
 * wordmodel.Prophet - OffensiveKickState + debugging
 * 
 * Revision 1.5.2.7 2005/07/21 11:24:38 endert Changed PConf handling
 * 
 * Revision 1.5.2.6 2005/07/20 17:59:01 wetzker new StateValues, AB +
 * fastDribbling (by now only in BodyDir), + started InterceptBallSituation
 * 
 * Revision 1.5.2.4 2005/07/18 08:59:54 wetzker debugged: - shootGoal, now
 * working quiet well (but still only a workaround) - attackInLine - bodyCycle()
 * was wrong :/ - dribbling added: - stamina management, use
 * p.correctDashPower(StaminaLevel) moved: - ControllerNumbers, as they aren't
 * use solo by the connection
 * 
 * Revision 1.5.2.3 2005/07/12 20:12:15 wetzker refactoring in actionbean
 * (mainly the kickActions) - if a kick-method returns 'null' it can't be kicked
 * with the given constraints - new freezeBall (still much to be done) debugging
 * (closeIntercept, wm.getPowerForDash (seit 6 Monaten falsch !!)) prob.
 * calculation in directpassState is now basd on correct ballSpeed
 * 
 * Revision 1.5.2.2 2005/07/10 19:20:24 wetzker composite dribbling and passing
 * (beta-version)
 * 
 * Revision 1.5.2.1 2005/07/10 18:32:39 endert extended version for shootGoal
 * with maxPower (PLAYER_SIZE + 0.1 distance is used)
 * 
 * Revision 1.5 2005/07/07 18:30:10 endert CompositeScoring added - other
 * ScoringStates will assess the ball on different kick-positions
 * 
 * Revision 1.4 2005/06/29 11:45:58 gamel moved Enum STATES from ActionBean to
 * AbstractState
 * 
 * Revision 1.3 2005/06/28 08:38:29 gamel States that use ActionBean, now give
 * themselves as an argument to ActionBean
 * 
 * Revision 1.2 2005/06/15 17:03:13 wetzker removed JIAC from Head + changes in
 * framework please report bugs or shortcomings some scenarios might not work
 * because of wrong imports
 * 
 * Revision 1.1.2.1 2005/06/09 12:31:34 endert Removal of JIAC Libraries and
 * dependencies from project, restructuring the framework and improve some
 * aspects (hoping it is an improvement)
 * 
 * Revision 1.7 2005/05/22 19:51:36 endert Improved states, performance due to
 * not creating states in composite states with "new"! All states should be
 * craeted on startup and only be modified over time (some exceptions may be
 * inserted later).
 * 
 * Revision 1.6 2005/05/19 15:25:58 endert Improvements of the state tactic
 * includes positioning, and marking opponents!
 * 
 * Revision 1.5 2005/05/16 16:51:45 karlb removed incorrect comment
 * 
 * Revision 1.4 2005/05/09 16:54:58 endert New State Framework: Superclass is
 * Abstract State, which is extended by SimpleState and CompositeState. All
 * Other States extend one of them. PlayMode and Conditions are (up to now) not
 * inherited, but can be set in Constructor for some states (PlayModes).
 * Evaluation of States considers postCondition as well.
 * 
 * Revision 1.3 2005/05/09 09:14:05 karlb Added CVS log tag
 * 
 */
